package com.xinfu.newproject.adapter.my_provider;


import android.view.View;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xinfu.newproject.R;
import com.xinfu.newproject.activity.ComplaintFeedbackActivity;
import com.xinfu.newproject.activity.HomeActivity;
import com.xinfu.newproject.activity.PaymentRecordsActivity;
import com.xinfu.newproject.activity.VisitorsRecordActivity;
import com.xinfu.newproject.bean.item.ItemBean;
import com.xinfu.newproject.ui.matter_repair.RepairPartsFragment;

/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class MyAdapter extends BaseQuickAdapter<ItemBean, BaseViewHolder> {

    private LinearLayout itemLL;
    private Integer integer;

    public MyAdapter() {
        super(R.layout.item_user_two_adapter);
    }

    public void addTextSize(Integer integer) {
        this.integer = integer;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, ItemBean item) {
        helper.setImageResource(R.id.item_user_two_iv, item.getItemImage());
        helper.setText(R.id.item_user_two_tv, item.getItemText());
        if (item.getItemText().equals("报修记录") && integer != null) {
            if (integer > 0) {
                helper.setText(R.id.item_user_two_tv2, integer + "");
                helper.getView(R.id.item_user_two_tv2).setVisibility(View.VISIBLE);
            } else {
                helper.getView(R.id.item_user_two_tv2).setVisibility(View.GONE);
            }
        } else {
            helper.getView(R.id.item_user_two_tv2).setVisibility(View.GONE);
        }
        itemLL = helper.getView(R.id.item_user_two_adapter_ll);
        itemLL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                switch (item.getItemPosition()) {
                    case 0:
                        ((HomeActivity) mContext).startIntentActivity(PaymentRecordsActivity.class, null);
                        break;
                    case 1:
                        ((HomeActivity) mContext).startIntentActivity(VisitorsRecordActivity.class, null);
                        break;
                    case 2:
                        ((HomeActivity) mContext).startIntentActivity(RepairPartsFragment.class, null);
                        break;
                    case 3:
                        ((HomeActivity) mContext).startIntentActivity(ComplaintFeedbackActivity.class, null);
                        break;
                }
            }
        });
    }


}
